home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / NetHack 3.1.3 / source / sys / unix / cpp1.shr next >
Encoding:
Text File  |  1993-08-01  |  53.4 KB  |  1,784 lines  |  [TEXT/R*ch]

  1. # This is a shell archive.  Save it in a file, remove anything before
  2. # this line, and then unpack it by entering "sh file".  Note, it may
  3. # create directories; files and directories will be owned by you and
  4. # have default permissions.
  5. #
  6. # This archive contains:
  7. #
  8. #    makefile.txt
  9. #    readme.txt
  10. #    cpp.mem
  11. #    cpp.h
  12. #    cppdef.h
  13. #    cpp2.c
  14. #
  15. echo x - makefile.txt
  16. sed 's/^X//' >makefile.txt << 'END-of-makefile.txt'
  17. X#
  18. X# The redefinition of strchr() and strrchr() are needed for
  19. X# Ultrix-32, Unix 4.2 bsd (and maybe some other Unices).
  20. X#
  21. XBSDDEFINE = -Dstrchr=index -Dstrrchr=rindex
  22. X#
  23. X# On certain systems, such as Unix System III, you may need to define
  24. X# $(LINTFLAGS) in the make command line to set system-specific lint flags.
  25. X#
  26. X# This Makefile assumes cpp will replace the "standard" preprocessor.
  27. X# Delete the reference to -DLINE_PREFIX=\"\" if cpp is used stand-alone.
  28. X# LINEFIX is a sed script filter that reinserts #line -- used for testing
  29. X# if LINE_PREFIX is set to "".   Note that we must stand on our heads to
  30. X# match the # and a line had better not begin with $.  By the way, what
  31. X# we really want is
  32. X#    LINEFIX = | sed "s/^#/#line/"
  33. X#
  34. XCPPDEFINE = -DLINE_PREFIX=\"\"
  35. XLINEFIX = | sed "s/^[^ !\"%-~]/&line/"
  36. X#
  37. X# Define OLD_PREPROCESSOR non-zero to make a preprocessor which is
  38. X# "as compatible as possible" with the standard Unix V7 or Ultrix
  39. X# preprocessors.  This is needed to rebuild 4.2bsd, for example, as
  40. X# the preprocessor is used to modify assembler code, rather than C.
  41. X# This is not recommended for current development.  OLD_PREPROCESSOR
  42. X# forces the following definitions:
  43. X#   OK_DOLLAR        FALSE    $ is not allowed in variables
  44. X#   OK_CONCAT        FALSE    # cannot concatenate tokens
  45. X#   COMMENT_INVISIBLE    TRUE    old-style comment concatenation
  46. X#   STRING_FORMAL    TRUE    old-style string expansion
  47. X#
  48. XOLDDEFINE = -DOLD_PREPROCESSOR=1
  49. X#
  50. X# DEFINES collects all -D arguments for cc and lint:
  51. X# Change DEFINES = $(BSDDEFINE) $(CPPDEFINE) $(OLDDEFINE)
  52. X# for an old-style preprocessor.
  53. X#
  54. X# DEFINES = $(BSDDEFINE) $(CPPDEFINE)
  55. XDEFINES = $(CPPDEFINE)
  56. X
  57. XCFLAGS = -O $(DEFINES)
  58. X
  59. X#
  60. X# ** compile cpp
  61. X#
  62. XSRCS = cpp1.c cpp2.c cpp3.c cpp4.c cpp5.c cpp6.c
  63. XOBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o
  64. Xcpp: $(OBJS)
  65. X    $(CC) $(CFLAGS) $(OBJS) -o cpp
  66. X
  67. X#
  68. X# ** Test cpp by preprocessing itself, compiling the result,
  69. X# ** repeating the process and diff'ing the result.  Note: this
  70. X# ** is not a good test of cpp, but a simple verification.
  71. X# ** The diff's should not report any changes.
  72. X# ** Note that a sed script may be executed for each compile
  73. X#
  74. Xtest:
  75. X    cpp cpp1.c $(LINEFIX) >old.tmp1.c
  76. X    cpp cpp2.c $(LINEFIX) >old.tmp2.c
  77. X    cpp cpp3.c $(LINEFIX) >old.tmp3.c
  78. X    cpp cpp4.c $(LINEFIX) >old.tmp4.c
  79. X    cpp cpp5.c $(LINEFIX) >old.tmp5.c
  80. X    cpp cpp6.c $(LINEFIX) >old.tmp6.c
  81. X    $(CC) $(CFLAGS) old.tmp[123456].c
  82. X    a.out cpp1.c >new.tmp1.c
  83. X    a.out cpp2.c >new.tmp2.c
  84. X    a.out cpp3.c >new.tmp3.c
  85. X    a.out cpp4.c >new.tmp4.c
  86. X    a.out cpp5.c >new.tmp5.c
  87. X    a.out cpp6.c >new.tmp6.c
  88. X    diff old.tmp1.c new.tmp1.c
  89. X    diff old.tmp2.c new.tmp2.c
  90. X    diff old.tmp3.c new.tmp3.c
  91. X    diff old.tmp4.c new.tmp4.c
  92. X    diff old.tmp5.c new.tmp5.c
  93. X    diff old.tmp6.c new.tmp6.c
  94. X    rm a.out old.tmp[123456].* new.tmp[123456].*
  95. X
  96. X#
  97. X# A somewhat more extensive test is provided by the "clock"
  98. X# program (which is not distributed).  Substitute your favorite
  99. X# macro-rich program here.
  100. X#
  101. Xclock:    clock.c cpp
  102. X    cpp clock.c $(LINEFIX) >temp.cpp.c
  103. X    cc temp.cpp.c -lcurses -ltermcap -o clock
  104. X    rm temp.cpp.c
  105. X
  106. X#
  107. X# ** Lint the code
  108. X#
  109. X
  110. Xlint:    $(SRCS)
  111. X    lint $(LINTFLAGS) $(DEFINES) $(SRCS)
  112. X
  113. X#
  114. X# ** Remove unneeded files
  115. X#
  116. Xclean:
  117. X    rm -f $(OBJS) cpp
  118. X
  119. X#
  120. X# ** Rebuild the archive files needed to distribute cpp
  121. X# ** Uses the Decus C archive utility.
  122. X#
  123. X
  124. Xarchc:    archc.c
  125. X    $(CC) $(CFLAGS) archc.c -o archc
  126. X
  127. Xarchx:    archx.c
  128. X    $(CC) $(CFLAGS) archx.c -o archx
  129. X
  130. Xarchive: archc
  131. X    archc readme.txt cpp.mem archx.c archc.c cpp.rno makefile.txt \
  132. X        cpp*.h >cpp1.arc
  133. X    archc cpp1.c cpp2.c cpp3.c >cpp2.arc
  134. X    archc cpp4.c cpp5.c cpp6.c >cpp3.arc
  135. X
  136. X#
  137. X# Object module dependencies
  138. X#
  139. X
  140. Xcpp1.o    :    cpp1.c cpp.h cppdef.h
  141. X
  142. Xcpp2.o    :    cpp2.c cpp.h cppdef.h
  143. X
  144. Xcpp3.o    :    cpp3.c cpp.h cppdef.h
  145. X
  146. Xcpp4.o    :    cpp4.c cpp.h cppdef.h
  147. X
  148. Xcpp5.o    :    cpp5.c cpp.h cppdef.h
  149. X
  150. Xcpp6.o    :    cpp6.c cpp.h cppdef.h
  151. X
  152. X
  153. END-of-makefile.txt
  154. echo x - readme.txt
  155. sed 's/^X//' >readme.txt << 'END-of-readme.txt'
  156. X
  157. XDecus cpp is a public-domain implementation of the C preprocessor.
  158. XIt runs on VMS native (Vax C), VMS compatibilty mode (Decus C),
  159. XRSX-11M, RSTS/E, P/OS, and RT11, as well as on several varieties
  160. Xof Unix, including Ultrix.  Decus cpp attempts to implement features
  161. Xin the Draft ANSI Standard for the C language.  It should be noted,
  162. Xhowever, that this standard is under active development:  the current
  163. Xdraft of the standard explicitly states that "readers are requested
  164. Xnot to specify or claim conformance to this draft."  Thus readers
  165. Xand users of Decus cpp should not assume that it conforms to the
  166. Xdraft standard, or that it will conform to the actual C language
  167. Xstandard.
  168. X
  169. XThese notes describe how to extract the cpp source files, configure it
  170. Xfor your needs, and mention a few design decisions that may be of interest
  171. Xto maintainers.
  172. X
  173. X            Installation
  174. X
  175. XBecause the primary development of cpp was not on Unix, it
  176. Xis distributed using the Decus C archive program (quite similar
  177. Xto the archiver published in Kernighan and Plauger's Software
  178. XTools).  To extract the files from the net.sources distribution,
  179. Xsave this message as cpp1.arc and the other two distribution
  180. Xfiles as cpp2.arc and cpp3.arc.  Then, using your favorite editor,
  181. Xlocate the archx.c program, just following the line beginning with
  182. X"-h- archx.c" -- the format of the distribution is just:
  183. X
  184. X    -h- readme.txt
  185. X      ... this file
  186. X    -h- cpp.mem
  187. X      ... description of cpp
  188. X    -h- archx.c
  189. X      ... archx.c program -- extracts archives
  190. X    -h- archc.c
  191. X      ... archc.c program -- creates archives
  192. X
  193. XCompile archx.c -- it shouldn't require any special editing.
  194. XThen run it as follows:
  195. X
  196. X    archx *.arc
  197. X
  198. XYou do not need to remove mail headers from the saved messages.
  199. X
  200. XYou should then read through cppdef.h to make sure the HOST and
  201. XTARGET (and other implementation-specific) definitions are set
  202. Xcorrectly for your machine, editing them as needed.
  203. X
  204. XYou may then copy makefile.txt to Makefile, editing it as needed
  205. Xfor your particular system.  On Unix, cpp should be compiled
  206. Xby make without further difficulty.  On other operating systems,
  207. Xyou should compile the six source modules, linking them together.
  208. XNote that, on Decus C based systems, you must extend the default
  209. Xstack allocation.  The Decus C build utility will create the
  210. Xappropriate command file.
  211. X
  212. X            Support Notes
  213. X
  214. XThe USENET distribution kit was designed to keep all submissions around
  215. X50,000 bytes:
  216. X
  217. Xcpp1.arc:
  218. X    readme.txt    This file
  219. X    cpp.mem        Documentation page (see below)
  220. X    archx.c        Archive extraction program
  221. X    archc.c        Archive construction program
  222. X    cpp.rno        Source for cpp.mem (see below)
  223. X    makefile.txt    Unix makefile -- copy to Makefile
  224. X    cpp.h        Main header file (structure def's and globals)
  225. X    cppdef.h    Configuration file (host and target definitions)
  226. X
  227. Xcpp2.arc:
  228. X    cpp1.c        Mainline code, documentation master sources
  229. X    cpp2.c        most #control processing
  230. X    cpp3.c        filename stuff and command line parsing
  231. Xcpp3.arc:
  232. X    cpp4.c        #define processor
  233. X    cpp5.c        #if <expr> processor
  234. X    cpp6.c        Support code (symbol table and I/O routines)
  235. X    
  236. XCpp intentionally does not rely on the presence of a full-scale
  237. Xmacro preprocessor, it does require the simple parameter substitution
  238. Xpreprocessor capabilities of Unix V6 and Decus C.  If your C
  239. Xlanguage lacks full preprocessing, you should make sure "nomacargs"
  240. Xis #define'd in cpp.h.  (This is done automatically by the Decus C
  241. Xcompiler.)
  242. X
  243. XThe documentation (manual page) for cpp is included as cpp.mem
  244. Xand cpp.rno.  Cpp.rno is in Dec Runoff format, built by a Decus C
  245. Xutility (getrno) from original source which is embedded in cpp1.c.
  246. XTo my knowledge, there is no equivalent program that creates
  247. Xthe nroff source appropriate for Unix.
  248. X
  249. XI would be happy to receive fixes to any problems you encounter.
  250. XAs I do not maintain distribution kit base-levels, bare-bones
  251. Xdiff listings without sufficient context are not very useful.
  252. XIt is unlikely that I can find time to help you with other
  253. Xdifficulties.
  254. X
  255. X            Acknowledgements
  256. X
  257. XI received a great deal of help from many people in debugging cpp.
  258. XAlan Feuer and Sam Kendall used "state of the art" run-time code
  259. Xcheckers to locate several errors.  Ed Keiser found problems when
  260. Xcpp was used on machines with different int and pointer sizes.
  261. XDave Conroy helped with the initial debugging, while Arthur Olsen
  262. Xand George Rosenberg found (and solved) several problems in the
  263. Xfirst USENET release.
  264. X
  265. XMartin Minow
  266. Xdecvax!minow
  267. X
  268. END-of-readme.txt
  269. echo x - cpp.mem
  270. sed 's/^X//' >cpp.mem << 'END-of-cpp.mem'
  271. X
  272. X
  273. X
  274. X
  275. X        1.0  C Pre-Processor
  276. X
  277. X
  278. X
  279. X                                    *******
  280. X                                    * cpp *
  281. X                                    *******
  282. X
  283. X
  284. X
  285. X        NAME:   cpp -- C Pre-Processor
  286. X
  287. X        SYNOPSIS:
  288. X
  289. X                cpp [-options] [infile [outfile]]
  290. X
  291. X        DESCRIPTION:
  292. X
  293. X                CPP reads a C source file, expands  macros  and  include
  294. X                files,  and writes an input file for the C compiler.  If
  295. X                no file arguments are given, CPP reads  from  stdin  and
  296. X                writes  to  stdout.   If  one file argument is given, it
  297. X                will define the input file,  while  two  file  arguments
  298. X                define  both  input and output files.  The file name "-"
  299. X                is a synonym for stdin or stdout as appropriate.
  300. X
  301. X                The following options are  supported.   Options  may  be
  302. X                given in either case.
  303. X
  304. X                -C              If set, source-file comments are written
  305. X                                to  the  output  file.   This allows the
  306. X                                output of CPP to be used as the input to
  307. X                                a  program,  such  as lint, that expects
  308. X                                commands embedded in specially-formatted
  309. X                                comments.
  310. X
  311. X                -Dname=value    Define the name  as  if  the  programmer
  312. X                                wrote
  313. X
  314. X                                    #define name value
  315. X
  316. X                                at the start  of  the  first  file.   If
  317. X                                "=value"  is  not  given, a value of "1"
  318. X                                will be used.
  319. X
  320. X                                On non-unix systems, all alphabetic text
  321. X                                will be forced to upper-case.
  322. X
  323. X                -E              Always return "success" to the operating
  324. X                                system,  even  if  errors were detected.
  325. X                                Note that some fatal errors, such  as  a
  326. X                                missing  #include  file,  will terminate
  327. X                                CPP, returning "failure" even if the  -E
  328. X                                option is given.
  329. X                                                                           Page 2
  330. X        cpp     C Pre-Processor
  331. X
  332. X
  333. X                -Idirectory     Add  this  directory  to  the  list   of
  334. X                                directories  searched for #include "..."
  335. X                                and #include <...> commands.  Note  that
  336. X                                there  is  no space between the "-I" and
  337. X                                the directory string.  More than one  -I
  338. X                                command   is   permitted.   On  non-Unix
  339. X                                systems   "directory"   is   forced   to
  340. X                                upper-case.
  341. X
  342. X                -N              CPP  normally  predefines  some  symbols
  343. X                                defining   the   target   computer   and
  344. X                                operating system.  If -N  is  specified,
  345. X                                no symbols will be predefined.  If -N -N
  346. X                                is  specified,  the   "always   present"
  347. X                                symbols,    __LINE__,    __FILE__,   and
  348. X                                __DATE__ are not defined.
  349. X
  350. X                -Stext          CPP normally assumes that  the  size  of
  351. X                                the  target  computer's  basic  variable
  352. X                                types is the same as the size  of  these
  353. X                                types  of  the host computer.  (This can
  354. X                                be  overridden  when  CPP  is  compiled,
  355. X                                however.)  The  -S option allows dynamic
  356. X                                respecification of these values.  "text"
  357. X                                is  a  string  of  numbers, separated by
  358. X                                commas, that  specifies  correct  sizes.
  359. X                                The sizes must be specified in the exact
  360. X                                order:
  361. X
  362. X                                    char short int long float double
  363. X
  364. X                                If you specify the option as  "-S*text",
  365. X                                pointers   to   these   types   will  be
  366. X                                specified.   -S*  takes  one  additional
  367. X                                argument  for  pointer to function (e.g.
  368. X                                int (*)())
  369. X
  370. X                                For   example,    to    specify    sizes
  371. X                                appropriate  for  a  PDP-11,  you  would
  372. X                                write:
  373. X
  374. X                                       c s i l f d func
  375. X                                     -S1,2,2,2,4,8,
  376. X                                    -S*2,2,2,2,2,2,2
  377. X
  378. X                                Note that all values must be specified.
  379. X
  380. X                -Uname          Undefine the name as if
  381. X
  382. X                                    #undef name
  383. X
  384. X                                were given.  On non-Unix systems, "name"
  385. X                                will be forced to upper-case.
  386. X                                                                           Page 3
  387. X        cpp     C Pre-Processor
  388. X
  389. X
  390. X                -Xnumber        Enable debugging code.  If no  value  is
  391. X                                given,  a value of 1 will be used.  (For
  392. X                                maintenence of CPP only.)
  393. X
  394. X
  395. X        PRE-DEFINED VARIABLES:
  396. X
  397. X                When CPP begins processing, the following variables will
  398. X                have been defined (unless the -N option is specified):
  399. X
  400. X                Target computer (as appropriate):
  401. X
  402. X                    pdp11, vax, M68000 m68000 m68k
  403. X
  404. X                Target operating system (as appropriate):
  405. X
  406. X                    rsx, rt11, vms, unix
  407. X
  408. X                Target compiler (as appropriate):
  409. X
  410. X                    decus, vax11c
  411. X
  412. X                The implementor may add definitions to this  list.   The
  413. X                default  definitions  match  the  definition of the host
  414. X                computer, operating system, and C compiler.
  415. X
  416. X                The following are always available unless undefined  (or
  417. X                -N was specified twice):
  418. X
  419. X                    __FILE__    The  input  (or  #include)  file   being
  420. X                                compiled (as a quoted string).
  421. X
  422. X                    __LINE__    The line number being compiled.
  423. X
  424. X                    __DATE__    The date and time of  compilation  as  a
  425. X                                Unix  ctime  quoted string (the trailing
  426. X                                newline is removed).  Thus,
  427. X
  428. X                                    printf("Bug at line %s,", __LINE__);
  429. X                                    printf(" source file %s", __FILE__);
  430. X                                    printf(" compiled on %s", __DATE__);
  431. X
  432. X
  433. X        DRAFT PROPOSED ANSI STANDARD CONSIDERATIONS:
  434. X
  435. X                The current  version  of  the  Draft  Proposed  Standard
  436. X                explicitly  states  that  "readers  are requested not to
  437. X                specify or claim conformance to this draft." Readers and
  438. X                users  of  Decus  CPP  should  not assume that Decus CPP
  439. X                conforms to the standard, or that it will conform to the
  440. X                actual C Language Standard.
  441. X
  442. X                When CPP is itself compiled, many features of the  Draft
  443. X                Proposed  Standard  that  are incompatible with existing
  444. X                                                                           Page 4
  445. X        cpp     C Pre-Processor
  446. X
  447. X
  448. X                preprocessors may be  disabled.   See  the  comments  in
  449. X                CPP's source for details.
  450. X
  451. X                The latest version of the Draft  Proposed  Standard  (as
  452. X                reflected in Decus CPP) is dated November 12, 1984.
  453. X
  454. X                Comments are removed from the input text.   The  comment
  455. X                is  replaced by a single space character.  The -C option
  456. X                preserves comments, writing them to the output file.
  457. X
  458. X                The '$' character is considered to be a letter.  This is
  459. X                a permitted extension.
  460. X
  461. X                The following new features of C are processed by CPP:
  462. X
  463. X                    #elif expression (#else #if)
  464. X                    '\xNNN' (Hexadecimal constant)
  465. X                    '\a' (Ascii BELL)
  466. X                    '\v' (Ascii Vertical Tab)
  467. X                    #if defined NAME 1 if defined, 0 if not
  468. X                    #if defined (NAME) 1 if defined, 0 if not
  469. X                    #if sizeof (basic type)
  470. X                    unary +
  471. X                    123U, 123LU Unsigned ints and longs.
  472. X                    12.3L Long double numbers
  473. X                    token#token Token concatenation
  474. X                    #include token Expands to filename
  475. X
  476. X                The Draft Proposed Standard has  extended  C,  adding  a
  477. X                constant string concatenation operator, where
  478. X
  479. X                    "foo" "bar"
  480. X
  481. X                is regarded as the single string "foobar".   (This  does
  482. X                not  affect  CPP's  processing but does permit a limited
  483. X                form of macro argument substitution into strings as will
  484. X                be discussed.)
  485. X
  486. X                The Standard Committee plans to add token  concatenation
  487. X                to  #define command lines.  One suggested implementation
  488. X                is as follows:  the sequence "Token1#Token2" is  treated
  489. X                as  if  the programmer wrote "Token1Token2".  This could
  490. X                be used as follows:
  491. X
  492. X                    #line 123
  493. X                    #define ATLINE foo#__LINE__
  494. X
  495. X                ATLINE would be defined as foo123.
  496. X
  497. X                Note that "Token2" must either have  the  format  of  an
  498. X                identifier or be a string of digits.  Thus, the string
  499. X
  500. X                    #define ATLINE foo#1x3
  501. X                                                                           Page 5
  502. X        cpp     C Pre-Processor
  503. X
  504. X
  505. X                generates two tokens:  "foo1" and "x3".
  506. X
  507. X                If the tokens T1 and T2 are concatenated into  T3,  this
  508. X                implementation operates as follows:
  509. X
  510. X                  1. Expand T1 if it is a macro.
  511. X                  2. Expand T2 if it is a macro.
  512. X                  3. Join the tokens, forming T3.
  513. X                  4. Expand T3 if it is a macro.
  514. X
  515. X                A macro formal parameter  will  be  substituted  into  a
  516. X                string or character constant if it is the only component
  517. X                of that constant:
  518. X
  519. X                    #define VECSIZE 123
  520. X                    #define vprint(name, size) \
  521. X                      printf("name" "[" "size" "] = {\n")
  522. X                      ... vprint(vector, VECSIZE);
  523. X
  524. X                expands (effectively) to
  525. X
  526. X                      vprint("vector[123] = {\n");
  527. X
  528. X                Note that  this  will  be  useful  if  your  C  compiler
  529. X                supports  the  new  string concatenation operation noted
  530. X                above.  As implemented here, if you write
  531. X
  532. X                    #define string(arg) "arg"
  533. X                      ... string("foo") ...
  534. X
  535. X                This implementation generates  "foo",  rather  than  the
  536. X                strictly  correct  ""foo"" (which will probably generate
  537. X                an error message).  This is, strictly speaking, an error
  538. X                in CPP and may be removed from future releases.
  539. X
  540. X        ERROR MESSAGES:
  541. X
  542. X                Many.  CPP prints warning or error messages if  you  try
  543. X                to     use     multiple-byte     character     constants
  544. X                (non-transportable) if you #undef a symbol that was  not
  545. X                defined,  or  if  your  program  has  potentially nested
  546. X                comments.
  547. X
  548. X        AUTHOR:
  549. X
  550. X                Martin Minow
  551. X
  552. X        BUGS:
  553. X
  554. X                The #if expression processor uses signed integers  only.
  555. X                I.e, #if 0xFFFFu < 0 may be TRUE.
  556. X
  557. END-of-cpp.mem
  558. echo x - cpp.h
  559. sed 's/^X//' >cpp.h << 'END-of-cpp.h'
  560. X
  561. X/*
  562. X *    I n t e r n a l   D e f i n i t i o n s    f o r   C P P
  563. X *
  564. X * In general, definitions in this file should not be changed.
  565. X */
  566. X
  567. X#ifndef    TRUE
  568. X#define    TRUE        1
  569. X#define    FALSE        0
  570. X#endif
  571. X#ifndef    EOS
  572. X/*
  573. X * This is predefined in Decus C
  574. X */
  575. X#define    EOS        '\0'        /* End of string        */
  576. X#endif
  577. X#define    EOF_CHAR    0        /* Returned by get() on eof    */
  578. X#define NULLST        ((char *) NULL)    /* Pointer to nowhere (linted)    */
  579. X#define    DEF_NOARGS    (-1)        /* #define foo vs #define foo()    */
  580. X
  581. X/*
  582. X * The following may need to change if the host system doesn't use ASCII.
  583. X */
  584. X#define    DEF_MAGIC    0x1D        /* Magic for #defines        */
  585. X#define    TOK_SEP        0x1E        /* Token concatenation delim.    */
  586. X#define COM_SEP        0x1F        /* Magic comment separator    */
  587. X
  588. X/*
  589. X * Note -- in Ascii, the following will map macro formals onto DEL + the
  590. X * C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will
  591. X * be ok as long as PAR_MAC is less than 33).  Note that the last PAR_MAC
  592. X * value is reserved for string substitution.
  593. X */
  594. X
  595. X#define    MAC_PARM    0x7F        /* Macro formals start here    */
  596. X#if PAR_MAC >= 33
  597. X    assertion fails -- PAR_MAC isn't less than 33
  598. X#endif
  599. X#define    LASTPARM    (PAR_MAC - 1)
  600. X
  601. X/*
  602. X * Character type codes.
  603. X */
  604. X
  605. X#define    INV        0        /* Invalid, must be zero    */
  606. X#define    OP_EOE        INV        /* End of expression        */
  607. X#define    DIG        1        /* Digit            */
  608. X#define    LET        2        /* Identifier start        */
  609. X#define    FIRST_BINOP    OP_ADD
  610. X#define    OP_ADD        3
  611. X#define    OP_SUB        4
  612. X#define    OP_MUL        5
  613. X#define    OP_DIV        6
  614. X#define    OP_MOD        7
  615. X#define    OP_ASL        8
  616. X#define    OP_ASR        9
  617. X#define    OP_AND        10        /* &, not &&            */
  618. X#define    OP_OR        11        /* |, not ||            */
  619. X#define    OP_XOR        12
  620. X#define    OP_EQ        13
  621. X#define    OP_NE        14
  622. X#define    OP_LT        15
  623. X#define    OP_LE        16
  624. X#define    OP_GE        17
  625. X#define    OP_GT        18
  626. X#define    OP_ANA        19        /* &&                */
  627. X#define    OP_ORO        20        /* ||                */
  628. X#define    OP_QUE        21        /* ?                */
  629. X#define    OP_COL        22        /* :                */
  630. X#define    OP_CMA        23        /* , (relevant?)        */
  631. X#define    LAST_BINOP    OP_CMA        /* Last binary operand        */
  632. X/*
  633. X * The following are unary.
  634. X */
  635. X#define    FIRST_UNOP    OP_PLU        /* First Unary operand        */
  636. X#define    OP_PLU        24        /* + (draft ANSI standard)    */
  637. X#define    OP_NEG        25        /* -                */
  638. X#define    OP_COM        26        /* ~                */
  639. X#define    OP_NOT        27        /* !                */
  640. X#define    LAST_UNOP    OP_NOT
  641. X#define    OP_LPA        28        /* (                */
  642. X#define    OP_RPA        29        /* )                */
  643. X#define    OP_END        30        /* End of expression marker    */
  644. X#define    OP_MAX        (OP_END + 1)    /* Number of operators        */
  645. X#define    OP_FAIL        (OP_END + 1)    /* For error returns        */
  646. X
  647. X/*
  648. X * The following are for lexical scanning only.
  649. X */
  650. X
  651. X#define    QUO        65        /* Both flavors of quotation    */
  652. X#define    DOT        66        /* . might start a number    */
  653. X#define    SPA        67        /* Space and tab        */
  654. X#define    BSH        68        /* Just a backslash        */
  655. X#define    END        69        /* EOF                */
  656. X
  657. X/*
  658. X * These bits are set in ifstack[]
  659. X */
  660. X#define    WAS_COMPILING    1        /* TRUE if compile set at entry    */
  661. X#define    ELSE_SEEN    2        /* TRUE when #else processed    */
  662. X#define    TRUE_SEEN    4        /* TRUE when #if TRUE processed    */
  663. X
  664. X/*
  665. X * Define bits for the basic types and their adjectives
  666. X */
  667. X
  668. X#define    T_CHAR          1
  669. X#define    T_INT          2
  670. X#define    T_FLOAT          4
  671. X#define    T_DOUBLE      8
  672. X#define    T_SHORT         16
  673. X#define    T_LONG         32
  674. X#define    T_SIGNED     64
  675. X#define    T_UNSIGNED    128
  676. X#define    T_PTR        256        /* Pointer            */
  677. X#define    T_FPTR        512        /* Pointer to functions        */
  678. X
  679. X/*
  680. X * The DEFBUF structure stores information about #defined
  681. X * macros.  Note that the defbuf->repl information is always
  682. X * in malloc storage.
  683. X */
  684. X
  685. Xtypedef struct defbuf {
  686. X    struct defbuf    *link;        /* Next define in chain    */
  687. X    char        *repl;        /* -> replacement    */
  688. X    int        hash;        /* Symbol table hash    */
  689. X    int        nargs;        /* For define(args)    */
  690. X    char        name[1];    /* #define name        */
  691. X} DEFBUF;
  692. X
  693. X/*
  694. X * The FILEINFO structure stores information about open files
  695. X * and macros being expanded.
  696. X */
  697. X
  698. Xtypedef struct fileinfo {
  699. X    char        *bptr;        /* Buffer pointer    */
  700. X    int        line;        /* for include or macro    */
  701. X    FILE        *fp;        /* File if non-null    */
  702. X    struct fileinfo    *parent;    /* Link to includer    */
  703. X    char        *filename;    /* File/macro name    */
  704. X    char        *progname;    /* From #line statement    */
  705. X    unsigned int    unrecur;    /* For macro recursion    */
  706. X    char        buffer[1];    /* current input line    */
  707. X} FILEINFO;
  708. X
  709. X/*
  710. X * The SIZES structure is used to store the values for #if sizeof
  711. X */
  712. X
  713. Xtypedef struct sizes {
  714. X    short    bits;            /* If this bit is set,        */
  715. X    short    size;            /* this is the datum size value    */
  716. X    short    psize;            /* this is the pointer size    */
  717. X} SIZES;
  718. X/*
  719. X * nomacarg is a built-in #define on Decus C.
  720. X */
  721. X
  722. X#ifdef    nomacarg
  723. X#define    cput        output        /* cput concatenates tokens    */
  724. X#else
  725. X#if COMMENT_INVISIBLE
  726. X#define    cput(c)        { if (c != TOK_SEP && c != COM_SEP) putchar(c); }
  727. X#else
  728. X#define    cput(c)        { if (c != TOK_SEP) putchar(c); }
  729. X#endif
  730. X#endif
  731. X
  732. X#ifndef    nomacarg
  733. X#define    streq(s1, s2)    (strcmp(s1, s2) == 0)
  734. X#endif
  735. X
  736. X/*
  737. X * Error codes.  VMS uses system definitions.
  738. X * Decus C codes are defined in stdio.h.
  739. X * Others are cooked to order.
  740. X */
  741. X
  742. X#if HOST == SYS_VMS
  743. X#include        <ssdef.h>
  744. X#include        <stsdef.h>
  745. X#define    IO_NORMAL    (SS$_NORMAL | STS$M_INHIB_MSG)
  746. X#define    IO_ERROR    SS$_ABORT
  747. X#endif
  748. X/*
  749. X * Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file
  750. X */
  751. X#ifndef    IO_NORMAL
  752. X#define    IO_NORMAL    0
  753. X#endif
  754. X#ifndef    IO_ERROR
  755. X#define    IO_ERROR    1
  756. X#endif
  757. X
  758. X/*
  759. X * Externs
  760. X */
  761. X
  762. Xextern int    line;            /* Current line number        */
  763. Xextern int    wrongline;        /* Force #line to cc pass 1    */
  764. Xextern char    type[];            /* Character classifier        */
  765. Xextern char    token[IDMAX + 1];    /* Current input token        */
  766. Xextern int    instring;        /* TRUE if scanning string    */
  767. Xextern int    inmacro;        /* TRUE if scanning #define    */
  768. Xextern int    errors;            /* Error counter        */
  769. Xextern int    recursion;        /* Macro depth counter        */
  770. Xextern char    ifstack[BLK_NEST];    /* #if information        */
  771. X#define    compiling ifstack[0]
  772. Xextern char    *ifptr;            /* -> current ifstack item    */
  773. Xextern char    *incdir[NINCLUDE];    /* -i directories        */
  774. Xextern char    **incend;        /* -> active end of incdir    */
  775. Xextern int    cflag;            /* -C option (keep comments)    */
  776. Xextern int    eflag;            /* -E option (ignore errors)    */
  777. Xextern int    nflag;            /* -N option (no pre-defines)    */
  778. Xextern int    rec_recover;        /* unwind recursive macros    */
  779. Xextern char    *preset[];        /* Standard predefined symbols    */
  780. Xextern char    *magic[];        /* Magic predefined symbols    */
  781. Xextern FILEINFO    *infile;        /* Current input file        */
  782. Xextern char    work[NWORK + 1];    /* #define scratch        */
  783. Xextern char    *workp;            /* Free space in work        */
  784. X#if    DEBUG
  785. Xextern int    debug;            /* Debug level            */
  786. X#endif
  787. Xextern int    keepcomments;        /* Don't remove comments if set    */
  788. Xextern SIZES    size_table[];        /* For #if sizeof sizes        */
  789. Xextern char    *getmem();        /* Get memory or die.        */
  790. Xextern DEFBUF    *lookid();        /* Look for a #define'd thing    */
  791. Xextern DEFBUF    *defendel();        /* Symbol table enter/delete    */
  792. Xextern char    *savestring();        /* Stuff string in malloc mem.    */
  793. Xextern char    *strcpy();
  794. Xextern char    *strcat();
  795. Xextern char    *strrchr();
  796. Xextern char    *strchr();
  797. Xextern long    time();
  798. X/* extern char    *sprintf();        /* Lint needs this        */
  799. END-of-cpp.h
  800. echo x - cppdef.h
  801. sed 's/^X//' >cppdef.h << 'END-of-cppdef.h'
  802. X/*
  803. X *           S y s t e m   D e p e n d e n t
  804. X *        D e f i n i t i o n s    f o r   C P P
  805. X *
  806. X * Definitions in this file may be edited to configure CPP for particular
  807. X * host operating systems and target configurations.
  808. X *
  809. X * NOTE: cpp assumes it is compiled by a compiler that supports macros
  810. X * with arguments.  If this is not the case (as for Decus C), #define
  811. X * nomacarg -- and provide function equivalents for all macros.
  812. X *
  813. X * cpp also assumes the host and target implement the Ascii character set.
  814. X * If this is not the case, you will have to do some editing here and there.
  815. X */
  816. X
  817. X/*
  818. X * This redundant definition of TRUE and FALSE works around
  819. X * a limitation of Decus C.
  820. X */
  821. X#ifndef    TRUE
  822. X#define    TRUE            1
  823. X#define    FALSE            0
  824. X#endif
  825. X
  826. X/*
  827. X * Define the HOST operating system.  This is needed so that
  828. X * cpp can use appropriate filename conventions.
  829. X */
  830. X#define    SYS_UNKNOWN        0
  831. X#define    SYS_UNIX        1
  832. X#define    SYS_VMS            2
  833. X#define    SYS_RSX            3
  834. X#define    SYS_RT11        4
  835. X#define    SYS_LATTICE        5
  836. X#define    SYS_ONYX        6
  837. X#define    SYS_68000        7
  838. X#define SYS_GCOS        8
  839. X#define SYS_IBM            9
  840. X#define SYS_OS            10
  841. X#define SYS_TSS            11
  842. X
  843. X#ifndef    HOST
  844. X#ifdef    unix
  845. X#define    HOST            SYS_UNIX
  846. X#else
  847. X#ifdef    vms
  848. X#define    HOST            SYS_VMS
  849. X#else
  850. X#ifdef    rsx
  851. X#define    HOST            SYS_RSX
  852. X#else
  853. X#ifdef    rt11
  854. X#define    HOST            SYS_RT11
  855. X#else
  856. X#ifdef dmert
  857. X#define HOST            SYS_DMERT
  858. X#else
  859. X#ifdef gcos
  860. X#define HOST            SYS_GCOS
  861. X#else
  862. X#ifdef ibm
  863. X#define HOST            SYS_IBM
  864. X#else
  865. X#ifdef os
  866. X#define HOST            SYS_OS
  867. X#else
  868. X#ifdef tss            
  869. X#define HOST            SYS_TSS
  870. X#endif
  871. X#endif
  872. X#endif
  873. X#endif
  874. X#endif
  875. X#endif
  876. X#endif
  877. X#endif
  878. X#endif
  879. X
  880. X#ifndef    HOST
  881. X#define    HOST            SYS_UNKNOWN
  882. X#endif
  883. X
  884. X/*
  885. X * We assume that the target is the same as the host system
  886. X */
  887. X#ifndef    TARGET
  888. X#define    TARGET            HOST
  889. X#endif
  890. X
  891. X/*
  892. X * In order to predefine machine-dependent constants,
  893. X * several strings are defined here:
  894. X *
  895. X * MACHINE    defines the target cpu (by name)
  896. X * SYSTEM    defines the target operating system
  897. X * COMPILER    defines the target compiler
  898. X *
  899. X *    The above may be #defined as "" if they are not wanted.
  900. X *    They should not be #defined as NULL.
  901. X *
  902. X * LINE_PREFIX    defines the # output line prefix, if not "line"
  903. X *        This should be defined as "" if cpp is to replace
  904. X *        the "standard" C pre-processor.
  905. X *
  906. X * FILE_LOCAL    marks functions which are referenced only in the
  907. X *        file they reside.  Some C compilers allow these
  908. X *        to be marked "static" even though they are referenced
  909. X *        by "extern" statements elsewhere.
  910. X *
  911. X * OK_DOLLAR    Should be set TRUE if $ is a valid alphabetic character
  912. X *        in identifiers (default), or zero if $ is invalid.
  913. X *        Default is TRUE.
  914. X *
  915. X * OK_CONCAT    Should be set TRUE if # may be used to concatenate
  916. X *        tokens in macros (per the Ansi Draft Standard) or
  917. X *        FALSE for old-style # processing (needed if cpp is
  918. X *        to process assembler source code).
  919. X *
  920. X * OK_DATE    Predefines the compilation date if set TRUE.
  921. X *        Not permitted by the Nov. 12, 1984 Draft Standard.
  922. X *
  923. X * S_CHAR etc.    Define the sizeof the basic TARGET machine word types.
  924. X *        By default, sizes are set to the values for the HOST
  925. X *        computer.  If this is inappropriate, see the code in
  926. X *        cpp3.c for details on what to change.  Also, if you
  927. X *        have a machine where sizeof (signed int) differs from
  928. X *        sizeof (unsigned int), you will have to edit code and
  929. X *        tables in cpp3.c (and extend the -S option definition.)
  930. X *
  931. X * CPP_LIBRARY    May be defined if you have a site-specific include directory
  932. X *        which is to be searched *before* the operating-system
  933. X *        specific directories.
  934. X */
  935. X
  936. X#if TARGET == SYS_LATTICE
  937. X/*
  938. X * We assume the operating system is pcdos for the IBM-PC.
  939. X * We also assume the small model (just like the PDP-11)
  940. X */
  941. X#define MACHINE            "i8086"
  942. X#define    SYSTEM            "pcdos"
  943. X#endif
  944. X
  945. X#if TARGET == SYS_ONYX
  946. X#define    MACHINE            "z8000"
  947. X#define    SYSTEM            "unix"
  948. X#endif
  949. X
  950. X#if TARGET == SYS_VMS
  951. X#define    MACHINE            "vax"
  952. X#define    SYSTEM            "vms"
  953. X#define    COMPILER        "vax11c"
  954. X#endif
  955. X
  956. X#if TARGET == SYS_RSX
  957. X#define    MACHINE            "pdp11"
  958. X#define    SYSTEM            "rsx"
  959. X#define    COMPILER        "decus"
  960. X#endif
  961. X
  962. X#if TARGET == SYS_RT11
  963. X#define    MACHINE            "pdp11"
  964. X#define    SYSTEM            "rt11"
  965. X#define    COMPILER        "decus"
  966. X#endif
  967. X
  968. X#if TARGET == SYS_68000
  969. X/*
  970. X * All three machine designators have been seen in various systems.
  971. X * Warning -- compilers differ as to sizeof (int).  cpp3 assumes that
  972. X * sizeof (int) == 2
  973. X */
  974. X#define    MACHINE            "M68000", "m68000", "m68k"
  975. X#define    SYSTEM            "unix"
  976. X#endif
  977. X
  978. X#if    TARGET == SYS_UNIX
  979. X#define    SYSTEM            "unix"
  980. X#ifdef    pdp11
  981. X#define    MACHINE            "pdp11"
  982. X#endif
  983. X#ifdef    vax
  984. X#define    MACHINE            "vax"
  985. X#endif
  986. X#ifdef u370
  987. X#define MACHINE            "u370"
  988. X#endif
  989. X#ifdef interdata
  990. X#define MACHINE            "interdata"
  991. X#endif
  992. X#ifdef u3b
  993. X#define MACHINE            "u3b"
  994. X#endif
  995. X#ifdef u3b5    
  996. X#define MACHINE            "u3b5"
  997. X#endif
  998. X#ifdef u3b2
  999. X#define MACHINE            "u3b2"
  1000. X#endif
  1001. X#ifdef u3b20d
  1002. X#define MACHINE            "u3b20d"
  1003. X#endif
  1004. X#endif
  1005. X#endif
  1006. X
  1007. X/*
  1008. X * defaults
  1009. X */
  1010. X
  1011. X#ifndef MSG_PREFIX
  1012. X#define MSG_PREFIX        "cpp: "
  1013. X#endif
  1014. X
  1015. X#ifndef LINE_PREFIX
  1016. X#ifdef    decus
  1017. X#define    LINE_PREFIX        ""
  1018. X#else
  1019. X#define LINE_PREFIX        "line"
  1020. X#endif
  1021. X#endif
  1022. X
  1023. X/*
  1024. X * OLD_PREPROCESSOR forces the definition of OK_DOLLAR, OK_CONCAT,
  1025. X * COMMENT_INVISIBLE, and STRING_FORMAL to values appropriate for
  1026. X * an old-style preprocessor.
  1027. X */
  1028. X#ifndef    OLD_PREPROCESSOR
  1029. X#define    OLD_PREPROCESSOR    FALSE
  1030. X#endif
  1031. X
  1032. X#if    OLD_PREPROCESSOR
  1033. X#define    OK_DOLLAR        FALSE
  1034. X#define    OK_CONCAT        FALSE
  1035. X#define    COMMENT_INVISIBLE    TRUE
  1036. X#define    STRING_FORMAL        TRUE
  1037. X#endif
  1038. X
  1039. X/*
  1040. X * RECURSION_LIMIT may be set to -1 to disable the macro recursion test.
  1041. X */
  1042. X#ifndef    RECURSION_LIMIT
  1043. X#define    RECURSION_LIMIT    1000
  1044. X#endif
  1045. X
  1046. X/*
  1047. X * BITS_CHAR may be defined to set the number of bits per character.
  1048. X * it is needed only for multi-byte character constants.
  1049. X */
  1050. X#ifndef    BITS_CHAR
  1051. X#define    BITS_CHAR        8
  1052. X#endif
  1053. X
  1054. X/*
  1055. X * BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series)
  1056. X * where 'ab' stores 'a' in the high-bits and 'b' in the low-bits.
  1057. X * It is set FALSE on machines (such as the PDP-11 and Vax-11)
  1058. X * where 'ab' stores 'a' in the low-bits and 'b' in the high-bits.
  1059. X * (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested.
  1060. X */
  1061. X#ifndef    BIG_ENDIAN
  1062. X#define    BIG_ENDIAN         FALSE
  1063. X#endif
  1064. X
  1065. X/*
  1066. X * COMMENT_INVISIBLE may be defined to allow "old-style" comment
  1067. X * processing, whereby the comment becomes a zero-length token
  1068. X * delimiter.  This permitted tokens to be concatenated in macro
  1069. X * expansions.  This was removed from the Draft Ansi Standard.
  1070. X */
  1071. X#ifndef    COMMENT_INVISIBLE
  1072. X#define    COMMENT_INVISIBLE    FALSE
  1073. X#endif
  1074. X
  1075. X/*
  1076. X * STRING_FORMAL may be defined to allow recognition of macro parameters
  1077. X * anywhere in replacement strings.  This was removed from the Draft Ansi
  1078. X * Standard and a limited recognition capability added.
  1079. X */
  1080. X#ifndef    STRING_FORMAL
  1081. X#define    STRING_FORMAL        FALSE
  1082. X#endif
  1083. X
  1084. X/*
  1085. X * OK_DOLLAR enables use of $ as a valid "letter" in identifiers.
  1086. X * This is a permitted extension to the Ansi Standard and is required
  1087. X * for e.g., VMS, RSX-11M, etc.   It should be set FALSE if cpp is
  1088. X * used to preprocess assembler source on Unix systems.  OLD_PREPROCESSOR
  1089. X * sets OK_DOLLAR FALSE for that reason.
  1090. X */
  1091. X#ifndef    OK_DOLLAR
  1092. X#define    OK_DOLLAR        TRUE
  1093. X#endif
  1094. X
  1095. X/*
  1096. X * OK_CONCAT enables (one possible implementation of) token concatenation.
  1097. X * If cpp is used to preprocess Unix assembler source, this should be
  1098. X * set FALSE as the concatenation character, #, is used by the assembler.
  1099. X */
  1100. X#ifndef    OK_CONCAT
  1101. X#define    OK_CONCAT        TRUE
  1102. X#endif
  1103. X
  1104. X/*
  1105. X * OK_DATE may be enabled to predefine today's date as a string
  1106. X * at the start of each compilation.  This is apparently not permitted
  1107. X * by the Draft Ansi Standard.
  1108. X */
  1109. X#ifndef    OK_DATE
  1110. X#define    OK_DATE        TRUE
  1111. X#endif
  1112. X
  1113. X/*
  1114. X * Some common definitions.
  1115. X */
  1116. X
  1117. X#ifndef    DEBUG
  1118. X#define    DEBUG            FALSE
  1119. X#endif
  1120. X
  1121. X/*
  1122. X * The following definitions are used to allocate memory for
  1123. X * work buffers.  In general, they should not be modified
  1124. X * by implementors.
  1125. X *
  1126. X * PAR_MAC    The maximum number of #define parameters (31 per Standard)
  1127. X *        Note: we need another one for strings.
  1128. X * IDMAX    The longest identifier, 31 per Ansi Standard
  1129. X * NBUFF    Input buffer size
  1130. X * NWORK    Work buffer size -- the longest macro
  1131. X *        must fit here after expansion.
  1132. X * NEXP        The nesting depth of #if expressions
  1133. X * NINCLUDE    The number of directories that may be specified
  1134. X *        on a per-system basis, or by the -I option.
  1135. X * BLK_NEST    The number of nested #if's permitted.
  1136. X */
  1137. X
  1138. X#define    IDMAX             31
  1139. X#define    PAR_MAC           (31 + 1)
  1140. X#define    NBUFF               1024
  1141. X#define    NWORK               1024
  1142. X#define    NEXP            128
  1143. X#define    NINCLUDE          7
  1144. X#define    NPARMWORK        (NWORK * 2)
  1145. X#define    BLK_NEST        32
  1146. X
  1147. X/*
  1148. X * Some special constants.  These may need to be changed if cpp
  1149. X * is ported to a wierd machine.
  1150. X *
  1151. X * NOTE: if cpp is run on a non-ascii machine, ALERT and VT may
  1152. X * need to be changed.  They are used to implement the proposed
  1153. X * ANSI standard C control characters '\a' and '\v' only.
  1154. X * DEL is used to tag macro tokens to prevent #define foo foo
  1155. X * from looping.  Note that we don't try to prevent more elaborate
  1156. X * #define loops from occurring.
  1157. X */
  1158. X
  1159. X#ifndef    ALERT
  1160. X#define    ALERT            '\007'        /* '\a' is "Bell"    */
  1161. X#endif
  1162. X
  1163. X#ifndef    VT
  1164. X#define    VT            '\013'        /* Vertical Tab CTRL/K    */
  1165. X#endif
  1166. X
  1167. X
  1168. X#ifndef    FILE_LOCAL
  1169. X#ifdef    decus
  1170. X#define    FILE_LOCAL        static
  1171. X#else
  1172. X#ifdef    vax11c
  1173. X#define    FILE_LOCAL        static
  1174. X#else
  1175. X#define    FILE_LOCAL                /* Others are global    */
  1176. X#endif
  1177. X#endif
  1178. X#endif
  1179. X
  1180. END-of-cppdef.h
  1181. echo x - cpp2.c
  1182. sed 's/^X//' >cpp2.c << 'END-of-cpp2.c'
  1183. X/*
  1184. X *                C P P 2 . C
  1185. X *
  1186. X *               Process #control lines
  1187. X *
  1188. X * Edit history
  1189. X * 13-Nov-84    MM    Split from cpp1.c
  1190. X */
  1191. X
  1192. X#include    <stdio.h>
  1193. X#include    <ctype.h>
  1194. X#include    "cppdef.h"
  1195. X#include    "cpp.h"
  1196. X#if HOST == SYS_VMS
  1197. X/*
  1198. X * Include the rms stuff.  (We can't just include rms.h as it uses the
  1199. X * VaxC-specific library include syntax that Decus CPP doesn't support.
  1200. X * By including things by hand, we can CPP ourself.)
  1201. X */
  1202. X#include    <nam.h>
  1203. X#include    <fab.h>
  1204. X#include    <rab.h>
  1205. X#include    <rmsdef.h>
  1206. X#endif
  1207. X
  1208. X/*
  1209. X * Generate (by hand-inspection) a set of unique values for each control
  1210. X * operator.  Note that this is not guaranteed to work for non-Ascii
  1211. X * machines.  CPP won't compile if there are hash conflicts.
  1212. X */
  1213. X
  1214. X#define    L_assert    ('a' + ('s' << 1))
  1215. X#define    L_define    ('d' + ('f' << 1))
  1216. X#define    L_elif        ('e' + ('i' << 1))
  1217. X#define    L_else        ('e' + ('s' << 1))
  1218. X#define    L_endif        ('e' + ('d' << 1))
  1219. X#define L_ident        ('i' + ('e' << 1))
  1220. X#define    L_if        ('i' + (EOS << 1))
  1221. X#define    L_ifdef        ('i' + ('d' << 1))
  1222. X#define    L_ifndef    ('i' + ('n' << 1))
  1223. X#define    L_include    ('i' + ('c' << 1))
  1224. X#define    L_line        ('l' + ('n' << 1))
  1225. X#define    L_nogood    (EOS + (EOS << 1))    /* To catch #i        */
  1226. X#define    L_pragma    ('p' + ('a' << 1))
  1227. X#define    L_sccs        ('s' + ('c' << 1))
  1228. X#define L_undef        ('u' + ('d' << 1))
  1229. X#if DEBUG
  1230. X#define    L_debug        ('d' + ('b' << 1))    /* #debug        */
  1231. X#define    L_nodebug    ('n' + ('d' << 1))    /* #nodebug        */
  1232. X#endif
  1233. X
  1234. Xint
  1235. Xcontrol(counter)
  1236. Xint        counter;    /* Pending newline counter        */
  1237. X/*
  1238. X * Process #control lines.  Simple commands are processed inline,
  1239. X * while complex commands have their own subroutines.
  1240. X *
  1241. X * The counter is used to force out a newline before #line, and
  1242. X * #pragma commands.  This prevents these commands from ending up at
  1243. X * the end of the previous line if cpp is invoked with the -C option.
  1244. X */
  1245. X{
  1246. X    register int        c;
  1247. X    register char        *tp;
  1248. X    register int        hash;
  1249. X    char            *ep;
  1250. X
  1251. X    c = skipws();
  1252. X    if (c == '\n' || c == EOF_CHAR)
  1253. X        return (counter + 1);
  1254. X    if (!isdigit(c))
  1255. X        scanid(c);            /* Get #word to token[]        */
  1256. X    else {
  1257. X        unget();            /* Hack -- allow #123 as a    */
  1258. X        strcpy(token, "line");    /* synonym for #line 123    */
  1259. X    }
  1260. X    hash = (token[1] == EOS) ? L_nogood : (token[0] + (token[2] << 1));
  1261. X    switch (hash) {
  1262. X    case L_assert:    tp = "assert";        break;
  1263. X    case L_define:    tp = "define";        break;
  1264. X    case L_elif:    tp = "elif";        break;
  1265. X    case L_else:    tp = "else";        break;
  1266. X    case L_endif:    tp = "endif";        break;
  1267. X    case L_ident:    tp = "ident";        break;
  1268. X    case L_if:    tp = "if";        break;
  1269. X    case L_ifdef:    tp = "ifdef";        break;
  1270. X    case L_ifndef:    tp = "ifndef";        break;
  1271. X    case L_include:    tp = "include";        break;
  1272. X    case L_line:    tp = "line";        break;
  1273. X    case L_pragma:    tp = "pragma";        break;
  1274. X    case L_sccs:    tp = "sccs";        break;
  1275. X    case L_undef:    tp = "undef";        break;
  1276. X#if DEBUG
  1277. X    case L_debug:    tp = "debug";        break;
  1278. X    case L_nodebug:    tp = "nodebug";        break;
  1279. X#endif
  1280. X    default:    hash = L_nogood;
  1281. X    case L_nogood:    tp = "";        break;
  1282. X    }
  1283. X    if (!streq(tp, token))
  1284. X        hash = L_nogood;
  1285. X    /*
  1286. X     * hash is set to a unique value corresponding to the
  1287. X     * control keyword (or L_nogood if we think it's nonsense).
  1288. X     */
  1289. X    if (infile->fp == NULL)
  1290. X        cwarn("Control line \"%s\" within macro expansion", token);
  1291. X    if (!compiling) {            /* Not compiling now    */
  1292. X        switch (hash) {
  1293. X        case L_if:                /* These can't turn    */
  1294. X        case L_ifdef:            /*  compilation on, but    */
  1295. X        case L_ifndef:            /*   we must nest #if's    */
  1296. X        if (++ifptr >= &ifstack[BLK_NEST])
  1297. X            goto if_nest_err;
  1298. X        *ifptr = 0;            /* !WAS_COMPILING    */
  1299. X        case L_line:            /* Many            */
  1300. X        /*
  1301. X         * Are pragma's always processed?
  1302. X         */
  1303. X        case L_ident:
  1304. X        case L_sccs:
  1305. X        case L_pragma:            /*  options        */
  1306. X        case L_include:            /*   are uninteresting    */
  1307. X        case L_define:            /*    if we        */
  1308. X        case L_undef:            /*     aren't        */
  1309. X        case L_assert:            /*      compiling.    */
  1310. Xdump_line:    skipnl();            /* Ignore rest of line    */
  1311. X        return (counter + 1);
  1312. X        }
  1313. X    }
  1314. X    /*
  1315. X     * Make sure that #line and #pragma are output on a fresh line.
  1316. X     */
  1317. X    if (counter > 0 && (hash == L_line || hash == L_pragma)) {
  1318. X        putchar('\n');
  1319. X        counter--;
  1320. X    }
  1321. X    switch (hash) {
  1322. X    case L_line:
  1323. X        /*
  1324. X         * Parse the line to update the line number and "progname"
  1325. X         * field and line number for the next input line.
  1326. X         * Set wrongline to force it out later.
  1327. X         */
  1328. X        c = skipws();
  1329. X        workp = work;            /* Save name in work    */
  1330. X        while (c != '\n' && c != EOF_CHAR) {
  1331. X        save(c);
  1332. X        c = get();
  1333. X        }
  1334. X        unget();
  1335. X        save(EOS);
  1336. X        /*
  1337. X         * Split #line argument into <line-number> and <name>
  1338. X         * We subtract 1 as we want the number of the next line.
  1339. X         */
  1340. X        line = atoi(work) - 1;        /* Reset line number    */
  1341. X        for (tp = work; isdigit(*tp) || type[*tp] == SPA; tp++)
  1342. X        ;                /* Skip over digits    */
  1343. X        if (*tp != EOS) {            /* Got a filename, so:    */
  1344. X        if (*tp == '"' && (ep = strrchr(tp + 1, '"')) != NULL) {
  1345. X            tp++;            /* Skip over left quote    */
  1346. X            *ep = EOS;            /* And ignore right one    */
  1347. X        }
  1348. X        if (infile->progname != NULL)    /* Give up the old name    */
  1349. X            free(infile->progname);    /* if it's allocated.    */
  1350. X            infile->progname = savestring(tp);
  1351. X        }
  1352. X        wrongline = TRUE;            /* Force output later    */
  1353. X        break;
  1354. X
  1355. X    case L_include:
  1356. X        doinclude();
  1357. X        break;
  1358. X
  1359. X    case L_define:
  1360. X        dodefine();
  1361. X        break;
  1362. X
  1363. X    case L_undef:
  1364. X        doundef();
  1365. X        break;
  1366. X
  1367. X    case L_else:
  1368. X        if (ifptr == &ifstack[0])
  1369. X        goto nest_err;
  1370. X        else if ((*ifptr & ELSE_SEEN) != 0)
  1371. X        goto else_seen_err;
  1372. X        *ifptr |= ELSE_SEEN;
  1373. X        if ((*ifptr & WAS_COMPILING) != 0) {
  1374. X        if (compiling || (*ifptr & TRUE_SEEN) != 0)
  1375. X            compiling = FALSE;
  1376. X        else {
  1377. X            compiling = TRUE;
  1378. X        }
  1379. X        }
  1380. X        break;
  1381. X
  1382. X    case L_elif:
  1383. X        if (ifptr == &ifstack[0])
  1384. X        goto nest_err;
  1385. X        else if ((*ifptr & ELSE_SEEN) != 0) {
  1386. Xelse_seen_err:    cerror("#%s may not follow #else", token);
  1387. X        goto dump_line;
  1388. X        }
  1389. X        if ((*ifptr & (WAS_COMPILING | TRUE_SEEN)) != WAS_COMPILING) {
  1390. X        compiling = FALSE;        /* Done compiling stuff    */
  1391. X        goto dump_line;            /* Skip this clause    */
  1392. X        }
  1393. X        doif(L_if);
  1394. X        break;
  1395. X
  1396. X    case L_if:
  1397. X    case L_ifdef:
  1398. X    case L_ifndef:
  1399. X        if (++ifptr >= &ifstack[BLK_NEST])
  1400. Xif_nest_err:    cfatal("Too many nested #%s statements", token);
  1401. X        *ifptr = WAS_COMPILING;
  1402. X        doif(hash);
  1403. X        break;
  1404. X
  1405. X    case L_endif:
  1406. X        if (ifptr == &ifstack[0]) {
  1407. Xnest_err:    cerror("#%s must be in an #if", token);
  1408. X        goto dump_line;
  1409. X        }
  1410. X        if (!compiling && (*ifptr & WAS_COMPILING) != 0)
  1411. X        wrongline = TRUE;
  1412. X        compiling = ((*ifptr & WAS_COMPILING) != 0);
  1413. X        --ifptr;
  1414. X        break;
  1415. X
  1416. X    case L_assert:
  1417. X        if (eval() == 0)
  1418. X        cerror("Preprocessor assertion failure", NULLST);
  1419. X        break;
  1420. X
  1421. X    case L_ident:
  1422. X    case L_sccs:
  1423. X        goto dump_line;
  1424. X        break;
  1425. X
  1426. X    case L_pragma:
  1427. X        /*
  1428. X         * #pragma is provided to pass "options" to later
  1429. X         * passes of the compiler.  cpp doesn't have any yet.
  1430. X         */
  1431. X        printf("#pragma ");
  1432. X        while ((c = get()) != '\n' && c != EOF_CHAR)
  1433. X        cput(c);
  1434. X        unget();
  1435. X        break;
  1436. X#if DEBUG
  1437. X    case L_debug:
  1438. X        if (debug == 0)
  1439. X        dumpdef("debug set on");
  1440. X        debug++;
  1441. X        break;
  1442. X
  1443. X    case L_nodebug:
  1444. X        debug--;
  1445. X        break;
  1446. X#endif
  1447. X
  1448. X    default:
  1449. X        /*
  1450. X         * Undefined #control keyword.
  1451. X         * Note: the correct behavior may be to warn and
  1452. X         * pass the line to a subsequent compiler pass.
  1453. X         * This would allow #asm or similar extensions.
  1454. X         */
  1455. X        cerror("Illegal # command \"%s\"", token);
  1456. X        break;
  1457. X    }
  1458. X    if (hash != L_include) {
  1459. X#if OLD_PREPROCESSOR || !VERBOSE
  1460. X        /*
  1461. X         * Ignore the rest of the #control line so you can write
  1462. X         *        #if    foo
  1463. X         *        #endif    foo
  1464. X         */
  1465. X        goto dump_line;            /* Take common exit    */
  1466. X#else
  1467. X        if (skipws() != '\n') {
  1468. X        cwarn("Unexpected text in #control line ignored", NULLST);
  1469. X        skipnl();
  1470. X        }
  1471. X#endif
  1472. X    }
  1473. X    return (counter + 1);
  1474. X}
  1475. X
  1476. XFILE_LOCAL
  1477. Xdoif(hash)
  1478. Xint        hash;
  1479. X/*
  1480. X * Process an #if, #ifdef, or #ifndef.  The latter two are straightforward,
  1481. X * while #if needs a subroutine of its own to evaluate the expression.
  1482. X *
  1483. X * doif() is called only if compiling is TRUE.  If false, compilation
  1484. X * is always supressed, so we don't need to evaluate anything.  This
  1485. X * supresses unnecessary warnings.
  1486. X */
  1487. X{
  1488. X    register int        c;
  1489. X    register int        found;
  1490. X
  1491. X    if ((c = skipws()) == '\n' || c == EOF_CHAR) {
  1492. X        unget();
  1493. X        goto badif;
  1494. X    }
  1495. X    if (hash == L_if) {
  1496. X        unget();
  1497. X        found = (eval() != 0);    /* Evaluate expr, != 0 is  TRUE    */
  1498. X        hash = L_ifdef;        /* #if is now like #ifdef    */
  1499. X    }
  1500. X    else {
  1501. X        if (type[c] != LET)        /* Next non-blank isn't letter    */
  1502. X        goto badif;        /* ... is an error        */
  1503. X        found = (lookid(c) != NULL); /* Look for it in symbol table    */
  1504. X    }
  1505. X    if (found == (hash == L_ifdef)) {
  1506. X        compiling = TRUE;
  1507. X        *ifptr |= TRUE_SEEN;
  1508. X    }
  1509. X    else {
  1510. X        compiling = FALSE;
  1511. X    }
  1512. X    return;
  1513. X
  1514. Xbadif:    cerror("#if, #ifdef, or #ifndef without an argument", NULLST);
  1515. X#if !OLD_PREPROCESSOR
  1516. X    skipnl();                /* Prevent an extra    */
  1517. X    unget();                /* Error message    */
  1518. X#endif
  1519. X    return;
  1520. X}
  1521. X
  1522. XFILE_LOCAL
  1523. Xdoinclude()
  1524. X/*
  1525. X * Process the #include control line.
  1526. X * There are three variations:
  1527. X *    #include "file"        search somewhere relative to the
  1528. X *                current source file, if not found,
  1529. X *                treat as #include <file>.
  1530. X *    #include <file>        Search in an implementation-dependent
  1531. X *                list of places.
  1532. X *    #include token        Expand the token, it must be one of
  1533. X *                "file" or <file>, process as such.
  1534. X *
  1535. X * Note: the November 12 draft forbids '>' in the #include <file> format.
  1536. X * This restriction is unnecessary and not implemented.
  1537. X */
  1538. X{
  1539. X    register int        c;
  1540. X    register int        delim;
  1541. X#if HOST == SYS_VMS
  1542. X    char            def_filename[NAM$C_MAXRSS + 1];
  1543. X#endif
  1544. X
  1545. X    delim = macroid(skipws());
  1546. X    if (delim != '<' && delim != '"')
  1547. X        goto incerr;
  1548. X    if (delim == '<')
  1549. X        delim = '>';
  1550. X    workp = work;
  1551. X    instring = TRUE;        /* Accept all characters    */
  1552. X    while ((c = get()) != '\n' && c != delim && c != EOF_CHAR)
  1553. X        save(c);            /* Put it away.            */
  1554. X    skipnl(); 
  1555. X    /*
  1556. X     * The draft is unclear if the following should be done.
  1557. X     */
  1558. X
  1559. X    while (--workp >= work && (type[*workp] == SPA))
  1560. X        ;                /* Trim blanks from filename    */
  1561. X
  1562. X/*
  1563. X *    if (*workp != delim)
  1564. X *        goto incerr; 
  1565. X */
  1566. X     *(workp + 1) = EOS;            /* Terminate filename    */
  1567. X    instring = FALSE;
  1568. X#if HOST == SYS_VMS
  1569. X    /*
  1570. X     * Assume the default .h filetype.
  1571. X     */
  1572. X    if (!vmsparse(work, ".H", def_filename)) {
  1573. X        perror(work);        /* Oops.            */
  1574. X        goto incerr;
  1575. X    }
  1576. X    else if (openinclude(def_filename, (delim == '"')))
  1577. X        return;
  1578. X#else
  1579. X    if (openinclude(work, (delim == '"')))
  1580. X        return;
  1581. X#endif
  1582. X    /*
  1583. X     * No sense continuing if #include file isn't there.
  1584. X     */
  1585. X    cfatal("Cannot open include file \"%s\"", work);
  1586. X
  1587. Xincerr:    cerror("#include syntax error", NULLST);
  1588. X    return;
  1589. X}
  1590. X
  1591. XFILE_LOCAL int
  1592. Xopeninclude(filename, searchlocal)
  1593. Xchar        *filename;        /* Input file name        */
  1594. Xint        searchlocal;        /* TRUE if #include "file"    */
  1595. X/*
  1596. X * Actually open an include file.  This routine is only called from
  1597. X * doinclude() above, but was written as a separate subroutine for
  1598. X * programmer convenience.  It searches the list of directories
  1599. X * and actually opens the file, linking it into the list of
  1600. X * active files.  Returns TRUE if the file was opened, FALSE
  1601. X * if openinclude() fails.  No error message is printed.
  1602. X */
  1603. X{
  1604. X    register char        **incptr;
  1605. X#if HOST == SYS_VMS
  1606. X#if NWORK < (NAM$C_MAXRSS + 1)
  1607. X    << error, NWORK isn't greater than NAM$C_MAXRSS >>
  1608. X#endif
  1609. X#endif
  1610. X    char            tmpname[NWORK];    /* Filename work area    */
  1611. X
  1612. X    if (searchlocal) {
  1613. X        /*
  1614. X         * Look in local directory first
  1615. X         */
  1616. X#if HOST == SYS_UNIX
  1617. X        /*
  1618. X         * Try to open filename relative to the directory of the current
  1619. X         * source file (as opposed to the current directory). (ARF, SCK).
  1620. X         */
  1621. X        if (filename[0] != '/'
  1622. X         && hasdirectory(infile->filename, tmpname))
  1623. X        strcat(tmpname, filename);
  1624. X        else {
  1625. X        strcpy(tmpname, filename);
  1626. X        }
  1627. X#else
  1628. X        if (!hasdirectory(filename, tmpname)
  1629. X         && hasdirectory(infile->filename, tmpname))
  1630. X        strcat(tmpname, filename);
  1631. X        else {
  1632. X        strcpy(tmpname, filename);
  1633. X        }
  1634. X#endif
  1635. X        if (openfile(tmpname))
  1636. X        return (TRUE);
  1637. X    }
  1638. X    /*
  1639. X     * Look in any directories specified by -I command line
  1640. X     * arguments, then in the builtin search list.
  1641. X     */
  1642. X    for (incptr = incdir; incptr < incend; incptr++) {
  1643. X        if (strlen(*incptr) + strlen(filename) >= (NWORK - 1))
  1644. X        cfatal("Filename work buffer overflow", NULLST);
  1645. X        else {
  1646. X#if HOST == SYS_UNIX
  1647. X        if (filename[0] == '/')
  1648. X            strcpy(tmpname, filename);
  1649. X        else {
  1650. X            sprintf(tmpname, "%s/%s", *incptr, filename);
  1651. X        }
  1652. X#else
  1653. X        if (!hasdirectory(filename, tmpname))
  1654. X            sprintf(tmpname, "%s%s", *incptr, filename);
  1655. X#endif
  1656. X        if (openfile(tmpname))
  1657. X            return (TRUE);
  1658. X        }
  1659. X    }
  1660. X    return (FALSE);
  1661. X}
  1662. X
  1663. XFILE_LOCAL int
  1664. Xhasdirectory(source, result)
  1665. Xchar        *source;    /* Directory to examine            */
  1666. Xchar        *result;    /* Put directory stuff here        */
  1667. X/*
  1668. X * If a device or directory is found in the source filename string, the
  1669. X * node/device/directory part of the string is copied to result and
  1670. X * hasdirectory returns TRUE.  Else, nothing is copied and it returns FALSE.
  1671. X */
  1672. X{
  1673. X#if HOST == SYS_UNIX
  1674. X    register char        *tp;
  1675. X
  1676. X    if ((tp = strrchr(source, '/')) == NULL)
  1677. X        return (FALSE);
  1678. X    else {
  1679. X        strncpy(result, source, tp - source + 1);
  1680. X        result[tp - source + 1] = EOS;
  1681. X        return (TRUE);
  1682. X    }
  1683. X#else
  1684. X#if HOST == SYS_VMS
  1685. X    if (vmsparse(source, NULLST, result)
  1686. X     && result[0] != EOS)
  1687. X        return (TRUE);
  1688. X    else {
  1689. X        return (FALSE);
  1690. X    }
  1691. X#else
  1692. X    /*
  1693. X     * Random DEC operating system (RSX, RT11, RSTS/E)
  1694. X     */
  1695. X    register char        *tp;
  1696. X
  1697. X    if ((tp = strrchr(source, ']')) == NULL
  1698. X     && (tp = strrchr(source, ':')) == NULL)
  1699. X        return (FALSE);
  1700. X    else {
  1701. X        strncpy(result, source, tp - source + 1);
  1702. X        result[tp - source + 1] = EOS;
  1703. X        return (TRUE);
  1704. X    }
  1705. X#endif
  1706. X#endif
  1707. X}
  1708. X
  1709. X#if HOST == SYS_VMS
  1710. X
  1711. X/*
  1712. X * EXP_DEV is set if a device was specified, EXP_DIR if a directory
  1713. X * is specified.  (Both set indicate a file-logical, but EXP_DEV
  1714. X * would be set by itself if you are reading, say, SYS$INPUT:)
  1715. X */
  1716. X#define DEVDIR (NAM$M_EXP_DEV | NAM$M_EXP_DIR)
  1717. X
  1718. XFILE_LOCAL int
  1719. Xvmsparse(source, defstring, result)
  1720. Xchar        *source;
  1721. Xchar        *defstring;    /* non-NULL -> default string.        */
  1722. Xchar        *result;    /* Size is at least NAM$C_MAXRSS + 1    */
  1723. X/*
  1724. X * Parse the source string, applying the default (properly, using
  1725. X * the system parse routine), storing it in result.
  1726. X * TRUE if it parsed, FALSE on error.
  1727. X *
  1728. X * If defstring is NULL, there are no defaults and result gets
  1729. X * (just) the node::[directory] part of the string (possibly "")
  1730. X */
  1731. X{
  1732. X    struct FAB    fab = cc$rms_fab;    /* File access block    */
  1733. X    struct NAM    nam = cc$rms_nam;    /* File name block    */
  1734. X    char        fullname[NAM$C_MAXRSS + 1];
  1735. X    register char    *rp;            /* Result pointer    */
  1736. X
  1737. X    fab.fab$l_nam = &nam;            /* fab -> nam        */
  1738. X    fab.fab$l_fna = source;            /* Source filename    */
  1739. X    fab.fab$b_fns = strlen(source);        /* Size of source    */
  1740. X    fab.fab$l_dna = defstring;        /* Default string    */
  1741. X    if (defstring != NULLST)
  1742. X        fab.fab$b_dns = strlen(defstring);    /* Size of default    */
  1743. X    nam.nam$l_esa = fullname;        /* Expanded filename    */
  1744. X    nam.nam$b_ess = NAM$C_MAXRSS;        /* Expanded name size    */
  1745. X    if (sys$parse(&fab) == RMS$_NORMAL) {    /* Parse away        */
  1746. X        fullname[nam.nam$b_esl] = EOS;    /* Terminate string    */
  1747. X        result[0] = EOS;            /* Just in case        */
  1748. X        rp = &result[0];
  1749. X        /*
  1750. X         * Remove stuff added implicitly, accepting node names and
  1751. X         * dev:[directory] strings (but not process-permanent files).
  1752. X         */
  1753. X        if ((nam.nam$l_fnb & NAM$M_PPF) == 0) {
  1754. X        if ((nam.nam$l_fnb & NAM$M_NODE) != 0) {
  1755. X            strncpy(result, nam.nam$l_node, nam.nam$b_node);
  1756. X            rp += nam.nam$b_node;
  1757. X            *rp = EOS;
  1758. X        }
  1759. X        if ((nam.nam$l_fnb & DEVDIR) == DEVDIR) {
  1760. X            strncpy(rp, nam.nam$l_dev, nam.nam$b_dev + nam.nam$b_dir);
  1761. X            rp += nam.nam$b_dev + nam.nam$b_dir;
  1762. X            *rp = EOS;
  1763. X        }
  1764. X        }
  1765. X        if (defstring != NULLST) {
  1766. X        strncpy(rp, nam.nam$l_name, nam.nam$b_name + nam.nam$b_type);
  1767. X        rp += nam.nam$b_name + nam.nam$b_type;
  1768. X        *rp = EOS;
  1769. X        if ((nam.nam$l_fnb & NAM$M_EXP_VER) != 0) {
  1770. X            strncpy(rp, nam.nam$l_ver, nam.nam$b_ver);
  1771. X            rp[nam.nam$b_ver] = EOS;
  1772. X        }
  1773. X        }
  1774. X        return (TRUE);
  1775. X    }
  1776. X    return (FALSE);
  1777. X}
  1778. X#endif
  1779. X
  1780. END-of-cpp2.c
  1781. exit
  1782.